﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Media;
using SmartLib.Core;

namespace SmartLib.UiTests.UiComponents.InputControls
{
	/// <summary>
	/// 
	/// </summary>
	public class AutoCompleteTextBoxTestsViewModel : ViewModelBase
	{
		/// <summary>
		/// Gets the hint items.
		/// </summary>
		public ObservableCollection<ColorWrapper> HintItems { get; private set; }

		/// <summary>
		/// Gets or sets the text.
		/// </summary>
		/// <value>
		/// The text.
		/// </value>
		public string Text
		{
			get { return GetValue<string>(); }
			set { SetValue(value); }
		}

		/// <summary>
		/// Gets or sets the hint text.
		/// </summary>
		/// <value>
		/// The hint text.
		/// </value>
		public string HintText
		{
			get { return GetValue<string>(); }
			set { SetValue(value); }
		}

		public AutoCompleteTextBoxTestsViewModel()
		{
			HintItems = new ObservableCollection<ColorWrapper>();
			var members = typeof(Colors).GetMembers(BindingFlags.Static | BindingFlags.Public);
			int count = 0;
			foreach (var info in members)
			{
				if (!(info is PropertyInfo)) continue;
				var propInfo = info as PropertyInfo;
				if (propInfo.PropertyType != typeof(Color)) continue;
				var color = (Color)propInfo.GetValue(null, Type.EmptyTypes);
				var wrapper = new ColorWrapper { Source = new SolidColorBrush(color), Name = propInfo.Name, Id = count++ };
				HintItems.Add(wrapper);
			}
		}
	}

	public class ColorWrapper
	{
		public int Id { get; set; }
		public Brush Source { get; set; }
		public string Name { get; set; }
	}
}
